package edu.ccut.saturn.studio.dialog;

import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;

import edu.ccut.saturn.studio.core.util.eclipse.Messages;
import edu.ccut.saturn.studio.logic.model.saturn.SaturnParameter;

public class TableViewerLableProvider implements ITableLabelProvider {

	public Image getColumnImage(Object element, int columnIndex) {
		return null;
	}

	public String getColumnText(Object element, int columnIndex) {
		SaturnParameter parameterVo = (SaturnParameter)element; 
		if (columnIndex == 0) {
			return parameterVo.getId();
		}
		if (columnIndex == 1) {
			return parameterVo.getValueKey();
		}
		if (columnIndex == 2) {
			return parameterVo.getName();
		}
		if (columnIndex == 3) {
			return parameterVo.getClassType();
		}
		if (columnIndex == 4) {
			if("in".equals(parameterVo.getPassingType())){
				return Messages.getString("TableViewerLableProvider.input"); //$NON-NLS-1$
			}
			if("out".equals(parameterVo.getPassingType())){
				return Messages.getString("TableViewerLableProvider.output"); //$NON-NLS-1$
			}
			if("in-out".equals(parameterVo.getPassingType())){
				return Messages.getString("TableViewerLableProvider.InputOutput"); //$NON-NLS-1$
			}
			return parameterVo.getPassingType();
		}
		if (columnIndex == 5) {
			if("1".equals(parameterVo.getScope())){
				return "logic";
			}
			if("2".equals(parameterVo.getScope())){
				return "request";
			}
			if("5".equals(parameterVo.getScope())){
				return "session";
			}
			if("10".equals(parameterVo.getScope())){
				return "application";
			}
			return parameterVo.getScope();
		}
		if (columnIndex == 6) {
			return parameterVo.getDescription();
		}
		
		return ""; 
	}

	public void addListener(ILabelProviderListener listener) {		
	}

	public void dispose() {
	}

	public boolean isLabelProperty(Object element, String property) {
		return false;
	}

	public void removeListener(ILabelProviderListener listener) {
	}
}